package com.webproject.service.impl.sysManager;

import com.webproject.core.Page;
import com.webproject.dao.sysManager.UserManagerDao;
import com.webproject.entity.sysManager.User;
import com.webproject.entity.sysManager.UserRoleRelation;
import com.webproject.service.sysManager.UserManagerService;

public class UserManagerServiceImpl implements UserManagerService {

	private UserManagerDao userManagerDao;
	public UserManagerDao getUserManagerDao() {
		return userManagerDao;
	}

	public void setUserManagerDao(UserManagerDao userManagerDao) {
		this.userManagerDao = userManagerDao;
	}

	@Override
	public void queryUser(Page page) {
		// TODO Auto-generated method stub
		page.setRows(userManagerDao.queryUser(page));
		page.setRecords(userManagerDao.queryUserCount(page));
	}

	@Override
	public void saveUser(User user) {
		// TODO Auto-generated method stub
		userManagerDao.saveUser(user);
	}

	@Override
	public void updateUser(User user) {
		// TODO Auto-generated method stub
		userManagerDao.updateUser(user);
	}

	@Override
	public void delUser(User user) {
		// TODO Auto-generated method stub
		//删除用户和角色的关系
		UserRoleRelation relation=new UserRoleRelation();
		relation.setUserId(user.getId());
		userManagerDao.delUserRoleRelation(relation);
		//删除用户
		userManagerDao.delUser(user);
	}

	@Override
	public void saveUserRoleRelation(UserRoleRelation relation) {
		// TODO Auto-generated method stub
		userManagerDao.saveUserRoleRelation(relation);
	}

	@Override
	public void delUserRoleRelation(UserRoleRelation relation) {
		// TODO Auto-generated method stub
		userManagerDao.delUserRoleRelation(relation);
	}

	@Override
	public User queryUser(User user) {
		// TODO Auto-generated method stub
		return userManagerDao.queryUser(user);
	}

}
